package com.tianya.common.model;

import java.io.File;
import java.io.Serializable;

import com.tianya.common.util.Utility;
import org.apache.struts2.ServletActionContext;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

@SuppressWarnings("serial")
public class SysInfo implements Serializable {

	private static int sessionTime = 3600;
	private static String dateFormat="yyyy/MM/dd";
	private static String fullDateFormat="yyyy/MM/dd HH:mm:ss";
	private static String dateInputFormat = "yyyy/MM/dd";
	private static String fullDateInputFormat = "yyyy/MM/dd HH:mm:ss";
	private static String mdDateInputFormat = "MMdd";//月日日期输入格式
	private static String mdDateFormat = "MM/dd";//月日日期输出格式
	private static String timeFormat="hh:mm";
	private static String fullTimeFormat="HH:mm:ss";
	private static String timeInputFormat="HHmm";
	private static String fullTimeInputFormat="HHmmss";
	private static int pageSize = 20;
	private static int maxCount = 1000;
	private static String theme ="common";
	private static int automsg=1;
	private static String key;
	private static String iv;
	private static String defaultpassword;
	private static String temporary;

	static
	{
		try
		{
			String str = ServletActionContext.getServletContext().getRealPath("WEB-INF/sysconfig.xml");
			File f = new File(str); 
			if(f!=null)
			{
				SAXReader reader = new SAXReader(); 
				Document doc = reader.read(f);
				if(doc != null)
				{
					Element root = doc.getRootElement(); 
					sessionTime = Utility.getInteger( root.elementText("sessionTime"));
					dateFormat = root.elementText("dateFormat");
					dateInputFormat = root.elementText("dateInputFormat");
					timeFormat = root.elementText("timeFormat");
					timeInputFormat = root.elementText("timeInputFormat");
					pageSize = Utility.getInteger(root.elementText("pageSize"));
					maxCount =Utility.getInteger(root.elementText("maxCount"));
					fullDateFormat =  root.elementText("fullDateFormat");
					fullDateInputFormat =  root.elementText("fullDateInputFormat");
					mdDateFormat = root.elementText("mdDateFormat");
					mdDateInputFormat = root.elementText("mdDateInputFormat");
					fullTimeFormat  =  root.elementText("fullTimeFormat");
					fullTimeInputFormat  =  root.elementText("fullTimeInputFormat");
					theme = root.elementText("theme");
					key = root.elementText("key");
					iv = root.elementText("iv");
					defaultpassword=root.elementText("defaultpassword");
					automsg= Utility.getInteger(root.elementText("automsg"));
					temporary=root.elementText("temporary");
			
				}
			}
		}
		catch(Exception e)
		{
			//默认值
			sessionTime = 3600;
			dateFormat="yyyy/MM/dd";
			fullDateFormat="yyyy/MM/dd HH:mm:ss";
			mdDateFormat = "MM/dd";
			dateInputFormat = "yyyy/MM/dd";
			fullDateInputFormat = "yyyy/MM/dd HH:mm:ss";
			mdDateInputFormat = "MMdd";
			timeFormat="hh:mm";
			fullTimeFormat="HH:mm:ss";
			timeInputFormat="HHmm";
			fullTimeInputFormat="HHmmss";
			pageSize = 20;
			maxCount = 1000;
			theme = "common";
			key = "rp51PiBD5Yb+6WvVRW1rQ6Fe6RXaAiAO";
			iv = "9ALahHEt";
			defaultpassword="123456";
			automsg=1; 
			temporary="c://";
		}
		
	}
	public static String getDefaultpassword() {
		return defaultpassword;
	}
	public static int getSessionTime() {
		return sessionTime;
	}
	public static String getDateFormat() {
		return dateFormat;
	}
	public static String getTimeFormat() {
		return timeFormat;
	}
	public static int getPageSize() {
		return pageSize;
	}
	public static int getMaxCount() {
		return maxCount;
	}
	public static String getDateInputFormat() {
		return dateInputFormat;
	}
	public static String getMdDateInputFormat() {
		return mdDateInputFormat;
	}
	public static String getMdDateFormat() {
		return mdDateFormat;
	}
	public static String getTimeInputFormat() {
		return timeInputFormat;
	}
	public static String getFullDateFormat() {
		return fullDateFormat;
	}
	public static String getFullDateInputFormat() {
		return fullDateInputFormat;
	}
	public static String getFullTimeFormat() {
		return fullTimeFormat;
	}
	public static String getFullTimeInputFormat() {
		return fullTimeInputFormat;
	}
	public static String getTheme() {
		return theme;
	}
	public static int getAutomsg() {
		return automsg;
	}
	public static String getIv() {
		return iv;
	}
	public static String getKey() {
		return key;
	}
	public static String getTemporary(){
		return  temporary;
	}
}
